//
//  OosListParser.m
//  oos4ios
//
//  Created by Pablo Gonzalez on 4/12/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import "OosListParser.h"
#import <oos4ios/Model/OosList.h>
#import "../GData/Common/Elements/GDataCategory.h"
#import "../GData/Common/Optional/Introspection/GDataAtomCategoryGroup.h"

@implementation OosListParser

static OosListParser *instance;

+ (OosListParser *)instance
{
    if (!instance) {
        instance = [[OosListParser alloc] init];
    }
    return instance;
}

-(NSArray *)parseCategories:(GDataAtomCategoryGroup *)feed
{
    NSMutableArray *result = [NSMutableArray array];
    OosList *list;
    for (GDataCategory *category in [feed categories]) {
        NSString *term = [category term];
        list = [OosList listFromTerm: term];
        list.label = [category term];
        [result addObject:list];
    }
    return result;
}

@end
